1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module shumate.MarkerLayer; 26 27 private import glib.ConstructionException; 28 private import glib.ListG; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import shumate.Layer; 32 private import shumate.Marker; 33 private import shumate.Viewport; 34 private import shumate.c.functions; 35 public import shumate.c.types; 36 private import std.algorithm; 37 38 39 /** 40 * Displays markers on the map. It is responsible for positioning markers 41 * correctly, marker selections and group marker operations. 42 */ 43 public class MarkerLayer : Layer 44 { 45 /** the main Gtk struct */ 46 protected ShumateMarkerLayer* shumateMarkerLayer; 47 48 /** Get the main Gtk struct */ 49 public ShumateMarkerLayer* getMarkerLayerStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return shumateMarkerLayer; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)shumateMarkerLayer; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (ShumateMarkerLayer* shumateMarkerLayer, bool ownedRef = false) 66 { 67 this.shumateMarkerLayer = shumateMarkerLayer; 68 super(cast(ShumateLayer*)shumateMarkerLayer, ownedRef); 69 } 70 71 72 /** */ 73 public static GType getType() 74 { 75 return shumate_marker_layer_get_type(); 76 } 77 78 /** 79 * Creates a new instance of #ShumateMarkerLayer. 80 * 81 * Params: 82 * viewport = the @ShumateViewport 83 * 84 * Returns: a new #ShumateMarkerLayer ready to be used as a container for the markers. 85 * 86 * Throws: ConstructionException GTK+ fails to create the object. 87 */ 88 public this(Viewport viewport) 89 { 90 auto __p = shumate_marker_layer_new((viewport is null) ? null : viewport.getViewportStruct()); 91 92 if(__p is null) 93 { 94 throw new ConstructionException("null returned by new"); 95 } 96 97 this(cast(ShumateMarkerLayer*) __p); 98 } 99 100 /** 101 * Creates a new instance of #ShumateMarkerLayer with the specified selection mode. 102 * 103 * Params: 104 * viewport = the @ShumateViewport 105 * mode = Selection mode 106 * 107 * Returns: a new #ShumateMarkerLayer ready to be used as a container for the markers. 108 * 109 * Throws: ConstructionException GTK+ fails to create the object. 110 */ 111 public this(Viewport viewport, GtkSelectionMode mode) 112 { 113 auto __p = shumate_marker_layer_new_full((viewport is null) ? null : viewport.getViewportStruct(), mode); 114 115 if(__p is null) 116 { 117 throw new ConstructionException("null returned by new_full"); 118 } 119 120 this(cast(ShumateMarkerLayer*) __p); 121 } 122 123 /** 124 * Adds the marker to the layer. 125 * 126 * Params: 127 * marker = a #ShumateMarker 128 */ 129 public void addMarker(Marker marker) 130 { 131 shumate_marker_layer_add_marker(shumateMarkerLayer, (marker is null) ? null : marker.getMarkerStruct()); 132 } 133 134 /** 135 * Fade in all markers in the layer with an animation 136 */ 137 public void animateInAllMarkers() 138 { 139 shumate_marker_layer_animate_in_all_markers(shumateMarkerLayer); 140 } 141 142 /** 143 * Fade out all markers in the layer with an animation 144 */ 145 public void animateOutAllMarkers() 146 { 147 shumate_marker_layer_animate_out_all_markers(shumateMarkerLayer); 148 } 149 150 /** 151 * Gets a copy of the list of all markers inserted into the layer. You should 152 * free the list but not its contents. 153 * 154 * Returns: the list 155 */ 156 public ListG getMarkers() 157 { 158 auto __p = shumate_marker_layer_get_markers(shumateMarkerLayer); 159 160 if(__p is null) 161 { 162 return null; 163 } 164 165 return new ListG(cast(GList*) __p); 166 } 167 168 /** 169 * Gets a list of selected markers in the layer. 170 * 171 * Returns: the list 172 */ 173 public ListG getSelected() 174 { 175 auto __p = shumate_marker_layer_get_selected(shumateMarkerLayer); 176 177 if(__p is null) 178 { 179 return null; 180 } 181 182 return new ListG(cast(GList*) __p); 183 } 184 185 /** 186 * Gets the selection mode of the layer. 187 * 188 * Returns: the selection mode of the layer. 189 */ 190 public GtkSelectionMode getSelectionMode() 191 { 192 return shumate_marker_layer_get_selection_mode(shumateMarkerLayer); 193 } 194 195 /** 196 * Hides all the markers in the layer 197 */ 198 public void hideAllMarkers() 199 { 200 shumate_marker_layer_hide_all_markers(shumateMarkerLayer); 201 } 202 203 /** 204 * Removes all markers from the layer. 205 */ 206 public void removeAll() 207 { 208 shumate_marker_layer_remove_all(shumateMarkerLayer); 209 } 210 211 /** 212 * Removes the marker from the layer. 213 * 214 * Params: 215 * marker = a #ShumateMarker 216 */ 217 public void removeMarker(Marker marker) 218 { 219 shumate_marker_layer_remove_marker(shumateMarkerLayer, (marker is null) ? null : marker.getMarkerStruct()); 220 } 221 222 /** 223 * Selects all selectable markers in the layer. 224 */ 225 public void selectAllMarkers() 226 { 227 shumate_marker_layer_select_all_markers(shumateMarkerLayer); 228 } 229 230 /** 231 * Selects a marker in this layer. 232 * 233 * If #ShumateMarkerLayer:selection-mode is %GTK_SELECTION_SINGLE or 234 * %GTK_SELECTION_BROWSE, all other markers will be unselected. If the mode is 235 * %GTK_SELECTION_NONE or @marker is not selectable, nothing will happen. 236 * 237 * Params: 238 * marker = a #ShumateMarker that is a child of @self 239 * 240 * Returns: %TRUE if the marker is now selected, otherwise %FALSE 241 */ 242 public bool selectMarker(Marker marker) 243 { 244 return shumate_marker_layer_select_marker(shumateMarkerLayer, (marker is null) ? null : marker.getMarkerStruct()) != 0; 245 } 246 247 /** 248 * Sets all markers draggable in the layer 249 */ 250 public void setAllMarkersDraggable() 251 { 252 shumate_marker_layer_set_all_markers_draggable(shumateMarkerLayer); 253 } 254 255 /** 256 * Sets all markers undraggable in the layer 257 */ 258 public void setAllMarkersUndraggable() 259 { 260 shumate_marker_layer_set_all_markers_undraggable(shumateMarkerLayer); 261 } 262 263 /** 264 * Sets the selection mode of the layer. 265 * 266 * NOTE: changing selection mode to %GTK_SELECTION_NONE, %GTK_SELECTION_SINGLE 267 * or %GTK_SELECTION_BROWSE will clear all previously selected markers. 268 * 269 * Params: 270 * mode = a #GtkSelectionMode value 271 */ 272 public void setSelectionMode(GtkSelectionMode mode) 273 { 274 shumate_marker_layer_set_selection_mode(shumateMarkerLayer, mode); 275 } 276 277 /** 278 * Shows all markers in the layer 279 */ 280 public void showAllMarkers() 281 { 282 shumate_marker_layer_show_all_markers(shumateMarkerLayer); 283 } 284 285 /** 286 * Unselects all markers in the layer. 287 */ 288 public void unselectAllMarkers() 289 { 290 shumate_marker_layer_unselect_all_markers(shumateMarkerLayer); 291 } 292 293 /** 294 * Unselects a marker in this layer. 295 * 296 * This works even if #ShumateMarkerLayer:selection-mode is 297 * %GTK_SELECTION_BROWSE. Browse mode only prevents user interaction, not the 298 * program, from unselecting a marker. 299 * 300 * Params: 301 * marker = a #ShumateMarker that is a child of @self 302 */ 303 public void unselectMarker(Marker marker) 304 { 305 shumate_marker_layer_unselect_marker(shumateMarkerLayer, (marker is null) ? null : marker.getMarkerStruct()); 306 } 307 308 /** 309 * Emitted when a marker in the layer is selected. 310 * 311 * Params: 312 * marker = The marker that was selected 313 */ 314 gulong addOnMarkerSelected(void delegate(Marker, MarkerLayer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 315 { 316 return Signals.connect(this, "marker-selected", dlg, connectFlags ^ ConnectFlags.SWAPPED); 317 } 318 319 /** 320 * Emitted when a marker in the layer is unselected. 321 * 322 * Params: 323 * marker = The marker that was unselected 324 */ 325 gulong addOnMarkerUnselected(void delegate(Marker, MarkerLayer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 326 { 327 return Signals.connect(this, "marker-unselected", dlg, connectFlags ^ ConnectFlags.SWAPPED); 328 } 329 }